import { IsArray, IsNotEmpty, IsNumber, IsOptional, IsString } from 'class-validator';

import { ApiProperty } from '@nestjs/swagger';
import { PageOptionsDto } from 'src/common/dto/page.dto';

export class Extend {
  @ApiProperty({ description: '扩展键名' })
  @IsNotEmpty()
  @IsString({ message: '字符串？' })
  name: string;

  @ApiProperty({ description: '扩展值' })
  @IsNotEmpty()
  @IsString({ message: '字符串？' })
  value: string;
}
export class CreateCategoryDto {
  @ApiProperty({ description: '分类名称' })
  @IsString({ message: '字符串？' })
  name: string;

  @ApiProperty({ description: '分类值' })
  @IsNumber()
  type: number;

  @ApiProperty({
    description: '关联文章',
    required: false,
  })
  @IsOptional()
  @IsArray()
  articles?: number[];
}
export class UpdateCategoryDto extends CreateCategoryDto {
  @ApiProperty({
    description: '需要更新的ID',
    type: Number,
  })
  id: number;
}
export class ListCategoryDto extends PageOptionsDto {
  @ApiProperty({ description: '分类名称' })
  @IsString({ message: '字符串？' })
  @IsOptional()
  name: string;

  @ApiProperty({ description: '分类值' })
  @IsNumber()
  @IsOptional()
  type: number;

  @ApiProperty({
    description: '关联文章',
    required: false,
  })
  @IsOptional()
  @IsArray()
  articles?: number[];
}
export class DelCategories {
  @ApiProperty({ description: '删除分类ID组' })
  id: number;
}
